#include <vector>
class Solution {
    vector<int> s;
    int a = INT_MAX;
public:
    void push(int value) {
        if (value < a)
        {
            a = value;
        }
        s.push_back(value);
    }
    void pop() {
        if (s.back() == a)
        {
            s.pop_back();
            a = INT_MAX;
            for (int e : s)
            {
                if (e < a)
                {
                    a = e;
                }
            }
        }
        else
        {
            s.pop_back();
        }
    }
    int top() {
        return s.back();
    }
    int min() {
        return a;
    }
};